home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- DESC: Common Computer and Group Lookup Functions for the Event Log Operations
-
- PLATFORMS: >= MS IE 4.0
-
- USAGE NOTES:
- ====================================================================== */
- // Initiate Computer Lookup
- var AC_CompStoreArr = new Array();
- var AC_GroupStoreArr = new Array();
-
- var WinServcDispArr = new Array();
- var WinServcDispArrIndex = 0;
- function processInitialLookup(Lmode) {
- CompRecCount = GrpLupRecCount = 0; // initialize the count
- WinServcDispArr.length = 0;
- WinServcDispArrIndex = 0;
- AC_CompStoreArr.length = 0;
- AC_GroupStoreArr.length = 0;
- if ( RpmCC_AL.ComputerLookup("*","*") ) {
- top.Rstatus.Pstat("Unable to start the LOOKUP request",true);
- }
- else { // waiting for OperationCompleteEvent
- ALupMode = Lmode;
- SetCursor("wait");
- top.banner.processStartComm();
- top.Rstatus.Pstat("One moment while LOOKUP request completes");
- }
- }
-
- // Add Computer to Store if NT/2000
- var CompRecLength = 6;
- var CompRecCount = 0;
- var CompIDArr = new Array();
- function processCompAddToStore(CNme,CDesc,Cid,Gid,OS) {
- var OSV = mapOSVer(OS);
- if ( (ALupMode == "STTCompLookup" || ALupMode == "SLCompLookup" || ALupMode == "WatchReport") ||
- (OSV.charAt(0) == "N" && OSV.charAt(1) == "T") ||
- (OSV != "Unknown" && (ALupMode == "FCCompLookup" || ALupMode == "DRCompLookup" || ALupMode == "PCCompLookup" )) ||
- (ALupMode == "DRCompLookup" && IsSNMP(OS)) ) {
- var i = CompRecCount * CompRecLength;
- AC_CompStoreArr[i++] = Cid;
- AC_CompStoreArr[i++] = Gid;
- AC_CompStoreArr[i++] = CNme;
- AC_CompStoreArr[i++] = CDesc;
- AC_CompStoreArr[i++] = "0";
- AC_CompStoreArr[i] = ""; // misc
- ++CompRecCount;
- }
- }
- function IsSNMP(OSVer) {
- var wrkarr = new Array();
- var sarr = new Array();
- wrkarr = OSVer.split("[]");
- OSVer = wrkarr[0];
- AgentVer = (wrkarr.length >= 2) ? wrkarr[1] : "";
- DomainName = (wrkarr.length >= 3) ? wrkarr[2] : "";
- SNMPInfo = (wrkarr.length >= 4) ? wrkarr[3] : "";
- sarr = SNMPInfo.split(":!");
- return ( (sarr[0] =="1") ? true : false);
- }
-
- function processELComputerOpError() {
- ALupMode = "";
- top.Rstatus.Pstat("An error occurred during COMPUTER LOOKUP operation",true);
- goResetWait();
- }
-
- // Computer Lookup Complete; Initiate Group Lookup
- function processComputerLookupComplete() {
- var Amode = ALupMode; // save
- ALupMode = "";
- if (CompRecCount == 0) { // check if any records found
- var emsg = "No Server/Computer record matches found";
- if ( Amode == "ELCompLookup" || Amode == "WinSrvcCompLookup" || Amode == "FCCompLookup" || Amode == "PCCompLookup") {
- emsg += " with NT or 2000 operating system";
- }
- top.Rstatus.Pstat(emsg,true);
- if ( top.banner.CurrentPageName == "AdminAlerts" ) {
- SetButtonState(UResetButton,"0");
- }
- }
- else if ( Amode == "DRCompLookup" && ALMode != "New" && ALMode != "Edit" ) {
- setTimeout("processAATree()",50); // delay 50 ms. then continue process Tree
- return;
- }
- else if ( RpmCC_AL.GroupLookup("","","") ) { // Group Lookup
- top.Rstatus.Pstat("Unable to start the GROUP LOOKUP request",true);
- }
- else {
- ALupMode = "ELGroupLookup";
- return; // exit and await Group Lookup
- }
- goResetWait();
- }
-
- var GrpLupRecCount = 0; // Count of records returned from Group Lookup operation
- var GroupRecLength = 4; // Length of a Group Lookup record in the Store
- /* Process Group LOOKUP RECORD Event */
- function processGroupLookupRecord(Gid,GrpName,GrpDesc) {
- // place data from Lookup Record into specified Store
- // Add to Storage
- var i = GrpLupRecCount * GroupRecLength;
- AC_GroupStoreArr[i++] = GrpName;
- AC_GroupStoreArr[i++] = Gid;
- AC_GroupStoreArr[i++] = GrpDesc;
- AC_GroupStoreArr[i] = 0;
- ++GrpLupRecCount;
- }
- /* Process DB Error in Group Lookup Operation */
- function processGroupOpError() {
- ALupMode = "";
- top.Rstatus.Pstat("An error occurred during GROUP LOOKUP operation",true);
- goResetWait();
- }
- var gocTid = null;
- function processGroupOpComplete() {
- ALupMode = "";
- goResetWait();
- if ( GrpLupRecCount == 0 ) {
- top.Rstatus.Pstat("No GROUP record matches found for LOOKUP request",true);
- }
- else {
- if ( top.banner.CurrentPageName == "AdminAlerts" ) {
- if ( CurrentAT == WinServicesType ) {
- if ( document.WinSrvcRadio.AL_WinSrvcDisp[1].checked ) {
- processWinServicesByService();
- return;
- }
- else {
- AL_CCOneWinServ.innerHTML = ""; // clear
- }
- }
- }
- processGroupTree(); // Go set up Specify Group Tree
- gocTid = setTimeout("processGOC_Done()",25);
- processFilterSet(); // Go set up Filter with info saved in Registry
- SpecificationsMade = true; // set Flag
- }
- }
- function processGOC_Done() {
- gocTid = null;
- processSpecifyButton(); // Go get parameters
- }
-
-
- function goResetWait() {
- WarningBox.style.display = "none";
- SetCursor("auto");
- top.banner.processStopCommX();
- }
- function goSetWait() {
- SetCursor("wait");
- top.banner.processStartComm();
- }
- // Process and Display the Group:Computer Tree
- var CCEs = null;
- var GroupExpandedCount = 0;
- function processGroupTree() {
- var Op = AL_CCOneEventLog; // preset
- setOutHeader("Groups : Servers/Devices Tree"); // define output table header
- if ( top.banner.CurrentPageName == "AdminAlerts" ) {
- if ( CurrentAT == WatchReportType ) {
- Op = AL_CCOneWatchReport;
- }
- else if ( CurrentAT == SNMPTrapType ) {
- Op = AL_CCOneSNMPTrap;
- }
- else if ( CurrentAT == WinServicesType ) {
- Op = AL_CCOneWinServ;
- setOutHeader("Groups : Servers/Workstations : Windows Services Tree"); // define output table header
- }
- else if ( CurrentAT == FileCheckType ) {
- Op = AL_CCOneFileCheck;
- setOutHeader("Groups : Servers/Workstations Tree"); // define output table header
- }
- else if ( CurrentAT == ProcessCheckType ) {
- Op = AL_CCOneProcessCheck;
- setOutHeader("Groups : Servers/Workstations Tree"); // define output table header
- }
- else if ( CurrentAT == SyslogCheckType ) {
- Op = AL_CCOneSyslogCheck;
- }
- }
-
- /* Format and Output Service tree list */
- if ( (top.banner.CurrentPageName == "AdminAlerts" && CurrentAT != WatchReportType) || top.banner.CurrentPageName == "AdminReports") {
- var SelT = "<table border='0' cellpadding='0' cellSpacing='1' width='490'>";
- SelT += "<tr><td width='100%' height='2' align='center' valign='top' class='optextb' style='background-color:graytext; color:captiontext'>Selections</td></tr></table>";
- CCEs = SelT+CCEs;
- }
- GroupExpandedCount = 0; // init
- for ( var i=0; i<GrpLupRecCount; i++) {
- CCEs += "<table border='0' cellpadding='0' cellSpacing='0' width='490'><tr><td width='25'> </td>";
- Iprefx = ( i+1 >= GrpLupRecCount ) ? "L" : "T";
- CCEs += "<td width='19' align='center'><img id='lima" + i + "' expanded='0' src='images/" + Iprefx + "plus.gif' style='cursor:hand' onclick='procGrpImgClick(this)' width='19' height='20'></td>";
- CCEs += "<td width='19' align='center'><img id='limb" + i + "' src='images/CloseImg.gif' style='cursor:hand' onclick='procGrpImgClick(this)' width='15' height='14' title='";
- CCEs += "'></td><td width='*' class='optext'>" + AC_GroupStoreArr[i*GroupRecLength] + "</td></tr></table>";
- CCEs += "<div id='lexp" + i + "' compcount=0></div>";
- }
- Op.insertAdjacentHTML("beforeEnd",CCEs);
- }
- /* Display Header for Service and Object:Counter Trees */
- function setOutHeader(Tstrg) {
- CCEs = "<table border='0' cellpadding='0' cellSpacing='0' width='490'>";
- CCEs += "<tr><td width='25'> </td>";
- CCEs += "<td width='19' height='20' align='center'><img src='images/topopen.gif' width='19' height='20'></td><td colspan='2' width='*' class='optextb'>" + Tstrg + "</td></tr></table>";
- }
-
- /* Process Click on Group in Group Tree */
- var CurExpGroupIx = null; // Index to Current Expanded Group
- var CurCmpIx = 0;
- var CmpsExpected = 0;
- function procGrpImgClick(SIm) {
- isx = SIm.id;
- if ( isx.charAt(0) != "l" ) { // if not a "limaxx"
- top.banner.beep();
- return;
- }
- var cx = isx.substring(4,isx.length); // Strip off index
-
- CurExpGroupIx = parseInt(cx,10);
- CObj = document.all["lima"+cx];
- EObj = document.all["lexp"+cx];
- FObj = document.all["limb"+cx];
- Cpfx = (CurExpGroupIx+1 >= GrpLupRecCount) ? "L" : "T";
-
- if ( CObj.expanded == "1" ) { // if currently expanded
- FObj.src = "images/CloseImg.gif";
- CObj.src = "images/" + Cpfx + "plus.gif";
- EObj.style.display = "none";
- //EObj.innerHTML = ""; // Contract
- CObj.expanded = "0"; // Set contracted
- GroupExpandedCount -= EObj.compcount; // decrement count of open computers
- }
- else { // otherwise Expand
- FObj.src = "images/OpenImg.gif";
- CCEs = ""; // initialize
- CObj.src = "images/" + Cpfx + "minus.gif";
- CObj.expanded = "1"; // Set expanded
- if ( EObj.compcount == 0 ) {
- CurCmpIx = 0; // initialize
- var GID = AC_GroupStoreArr[(cx*GroupRecLength)+1]; // get Group ID
- // Add Computers to the Tree for This Group
- var carr = new Array();
- for ( var i=0, j=0, k=0; i<CompRecCount; ++i ) {
- j = (i*CompRecLength); // index to Computer entry in store
- // Match on Group ID
- if ( GID == AC_CompStoreArr[j+1] ) {
- carr[k] = j; // save index in array
- ++k; // bump computer count
- }
- }
- if ( k==0 ) {
- if ( top.banner.CurrentPageName == "AdminAlerts" ) {
- if ( (CurrentAT != EventLogType && CurrentAT != WinServicesType && CurrentAT != FileCheckType && CurrentAT != ProcessCheckType) ) {
- top.Rstatus.Pstat("Group is empty!",true);
- alert("Group is empty!");
- return;
- }
- }
- if ( arguments.length == 2 ) {
- return;
- }
- top.Rstatus.Pstat("Group has no NT/2000 Servers/Computers with MonitorIT Agent!",true);
- alert("Group has no NT/2000 Servers/Computers with MonitorIT Agent!");
- return;
- }
- CmpsExpected = k; // set number of computers matching
- for ( var i=0; i<k; i++ ) {
- j = carr[i]; // get index to computer that matches
- processTreeComputer(AC_CompStoreArr[j+2],AC_CompStoreArr[j+3],AC_CompStoreArr[j+4],j);
- AC_CompStoreArr[j+5] = i; // Computer index into Group Tree
- }
- EObj.compcount = k; // set number computers opened
- EObj.insertAdjacentHTML("beforeEnd",CCEs);
- }
- GroupExpandedCount += EObj.compcount; // increment total number of computers opened
- EObj.style.display = "";
- }
- if ( arguments.length == 1 ) {
- CObj.scrollIntoView(true);
- }
- // enable SelectAll/UnselectAll buttons if computers opened
- checkSelUnselButtons();
- }
- function SetButtonState(BtObj,BState) {
- //BtObj.className = (BState == "0") ? "BoxButton" : "BoxButtonD";
- BtObj.disabled = (BState == "0") ? "" : "disabled";
- BtObj.bdis = BState;
- }
-
- function processTreeComputer(CmpNme,CmpDesc,SState,CSIx) {
- var WST = (top.banner.CurrentPageName == "AdminAlerts" && CurrentAT == WinServicesType) ? true : false;
- var Opfx = (CurExpGroupIx+1 >= GrpLupRecCount) ? "White" : "I";
- var Mpfx = (CurCmpIx+1 == CmpsExpected) ? "L" : "T";
-
- CCEs += "<table border='0' cellpadding='0' cellSpacing='0' width='490'>";
- CCEs += "<tr><td width='25'> </td><td width='19' height='20' align='center'><img src='images/" + Opfx + ".gif' width='19' height='20'></td>";
- CCEs += "<td width='19' height='20' align='center'><img src='images/" + Mpfx + ".gif' width='19' height='20'></td>";
- CCEs += "<td width='11' align='center'><img id='xima" + CurExpGroupIx + "_" + CurCmpIx;
-
- if ( WST ) {
- CCEs += "' checked='0' src='images/Plus.gif' width='11' height='11'";
- CmpImg = "Computer.gif";
- }
- else if ( SState == "1" ) {
- CCEs += "' checked='1' src='images/";
- CCEs += "Checked.gif' width='9' height='9'";
- CmpImg = selectImage;
- }
- else {
- CCEs += "' checked='0' src='images/";
- CCEs += "Unchecked.gif' width='9' height='9'";
- CmpImg = "Computer.gif";
- }
-
- CCEs += " compix='" +CSIx+"' style='cursor:hand' onclick='procELCmpImgClick(this)'></td>";
- CCEs += "<td width='19' align='center'><img id='zimb" + CurExpGroupIx + "_" + CurCmpIx + "' src='images/"+CmpImg+"' style='cursor:hand' onclick='procELCmpImgClick(this)' width='15' height='16' title='";
- CCEs += CmpDesc + "'></td>";
- CCEs += "<td width='*' id='zimc" + CurExpGroupIx + "_" + CurCmpIx;
- CCEs += "' style='cursor:hand' onclick='procELCmpImgClick(this)' class='optext'>" + CmpNme + "</td>";
- CCEs += "</tr></table>";
- if ( WST ) {
- CCEs += "<div id='sexp" + CurExpGroupIx + "_" + CurCmpIx + "' wslrec='' checkedsrvcs=0 srvcssel=0 srvcsdisp=0 style='display:none'></div>";
- }
- ++CurCmpIx; // bump index
- }
-
- /* Process Click to Check or Uncheck a Computer */
- function procELCmpImgClick(CmpIm) {
- var WST = (top.banner.CurrentPageName == "AdminAlerts" && CurrentAT == WinServicesType) ? true : false;
- var isx = CmpIm.id;
- if ( isx.charAt(0) != "x" && isx.charAt(0) != "z")
- return;
- var cx = isx.substring(4,isx.length); // Strip off index
- lx = cx.lastIndexOf("_"); // derive suffix to the Computer DIV ID
- var dx = cx.substring(0,lx);
-
- var CObj = document.all["xima"+cx]; // Clicked Computer Entry
- var FObj = document.all["zimb"+cx];
- CSIx = parseInt(CObj.compix,10);
- if ( WST ) { // Windows Services
- CurExpGrpCompIx = cx;
- var EObj = document.all["sexp"+CurExpGrpCompIx];
- if ( CObj.checked == "1" ) { // if currently Expanded, Contract
- CObj.src = "images/Plus.gif";
- CObj.checked = "0"; // Set Unchecked
- EObj.style.display = "none";
- }
- else { // otherwise Expand Windows Services
- CObj.src = "images/Minus.gif";
- CObj.checked = "1"; // Set Checked
- if ( EObj.wslrec != "" ) {
- EObj.style.display = ""; //processWinSrvcsLookupRecord(WSLrec);
- }
- else if ( RpmCC_AL.NTServicesLinkListLookup(AC_CompStoreArr[CSIx],"") ) { // Services Lookup
- top.Rstatus.Pstat("Unable to start the Win Services LOOKUP request",true);
- goResetWait();
- }
- else {
- ALupMode = "WinSrvcsLookup";
- return; // exit and await Services Lookup
- }
- }
- }
- else {
- if ( CObj.checked == "1" ) { // if currently Checked, Uncheck
- FObj.src = "images/Computer.gif";
- CObj.src = "images/Unchecked.gif";
- CObj.checked = "0"; // Set Unchecked
- AC_CompStoreArr[CSIx+4] = "0";
- }
- else { // otherwise Check
- FObj.src = "images/"+selectImage;
- CObj.src = "images/Checked.gif";
- CObj.checked = "1"; // Set Checked
- AC_CompStoreArr[CSIx+4] = "1";
- }
- }
- SpecificationsMade = true; // flag that a change has been made
- }
-
- // Process SelectALL or UnselectALL
- function processSelect(Pflg) {
- var GObj = null, CObj = null;
- // Look for each open/expanded Group
- for ( var i=0; i<GrpLupRecCount; i++ ) {
- GObj = document.all["lima"+i];
- if ( GObj.expanded == "1" ) {
- GObj = document.all["lexp"+i];
- // if Group expanded, process each computer
- for ( var j=0; j<GObj.compcount; j++ ) {
- CObj = document.all["xima"+i+"_"+j]; // computer entry in tree
- if (CObj.checked == Pflg) {
- procELCmpImgClick(CObj); // go process
- }
- }
- }
- }
- }
-
-